#ifndef MAPNETWORK_H
#define MAPNETWORK_H

#include <QObject>
#include <QDebug>
#include <QHttp>
#include <QVector>
#include <QPixmap>
#include "imagemanager.h"

class ImageManager;
class MapNetwork : QObject
{
    Q_OBJECT

public:
    MapNetwork(ImageManager* parent);
    ~MapNetwork();

    void loadImage(const QString& host, const QString& url);

    bool imageIsLoading(QString url);

    /*!
         * Aborts all current loading threads.
         * This is useful when changing the zoom-factor, though newly needed images loads faster
         */
    void abortLoading();
    void setProxy(QString host, int port);

private:
    ImageManager* parent;
    QHttp* http;
    QMap<int, QString> loadingMap;
    qreal loaded;
    QMutex vectorMutex;
    MapNetwork& operator=(const MapNetwork& rhs);
    MapNetwork(const MapNetwork& old);

private slots:
    void requestFinished(int id, bool error);
};
#endif
